/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MOM;

import java.util.ArrayList;

/**
 *
 * @author Huy
 */
public class Center {
	public static ArrayList<Topic> topics = new ArrayList<>();
	private static Topic findTopic(int id)
	{
		for (Topic topic : topics) {
			if(topic.id==id) {
				return topic;
			}
		}
		return null;
	}
	public static void subcribe(int i,Subcriber sub)
	{
		Topic topic = findTopic(i);
		if(topic != null) {
			topic.subcribe(sub);
		}
	}
	public static void post(int i,Message msg)
	{
		Topic topic = findTopic(i);
		if(topic != null) {
			topic.post(msg);
		}
	}
	
}
